﻿#include "Clock.h"

#include <QBoxLayout>
#include <QLCDNumber>
#include <QTime>
#include <QTimer>

Clock::Clock(QWidget *parent) : QWidget(parent)
{
    lcd_time = new QLCDNumber(this);
    lcd_time->setObjectName(QString::fromUtf8("lcd_time"));
    //lcd_time->setMinimumSize(QSize(0, 50));
    lcd_time->setDigitCount(8);
    //lcd_time->setStyleSheet(QString::fromUtf8("color:rgb(255, 255, 255)"));
    lcd_time->setFrameShape(QFrame::NoFrame);

    QHBoxLayout* verticalLayout = new QHBoxLayout(this);
    verticalLayout->addWidget(lcd_time);

    QTimer *timer = new QTimer(this);
    connect(timer, &QTimer::timeout, this, &Clock::updateClock);
    timer->start(1000);
}

void Clock::updateClock()
{
    QTime time = QTime::currentTime();
    QString text = time.toString("hh:mm:ss");
//    if ((time.second() % 2) == 0)
//        text[2] = ' ';
    lcd_time->display(text);
}
